﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace AgvDemo
{
    public partial class TrafficManageForm : Form
    {
        int modes = 0;


        public delegate void AddDataDele(int areaNum,int lockCard,string unLockCard);
        public event AddDataDele AddEvent;
        public event AddDataDele UpdateEvent;
        public TrafficManageForm(int mode, DataGridViewRow dgvrc)
        {
            InitializeComponent();

            if (mode == 1)
            {
                this.Text = "新增";

              
            }
            else
            {
                this.Text = "更新";

               

                textBox1.Text = dgvrc.Cells[0].Value.ToString();
                textBox2.Text = dgvrc.Cells[1].Value.ToString();
                textBox3.Text = dgvrc.Cells[2].Value.ToString();
            }



            modes = mode;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (modes == 1)//增加
            {
                try
                {
                    
                        AddEvent(int.Parse(textBox1.Text), int.Parse(textBox2.Text), textBox3.Text);
                   
                }
                catch
                {
                    MessageBox.Show("异常");
                }
            }
            else
            {
                try
                {
                    UpdateEvent(int.Parse(textBox1.Text), int.Parse(textBox2.Text), textBox3.Text);
                   
                }
                catch
                {
                    MessageBox.Show("异常");
                }
            }
        }
    }
}
